/**
 * @file STL_RtspRequest.h
 * @author Derek Liu (yjkhtddx@sina.com)
 * @brief 
 * @version 0.1
 * @date 2021-02-19
 * 
 * @copyright Copyright Sci-Tech Laboratories (c) 2021
 * 
 */

#ifndef __STL_RTSP_REQUEST_H__
#define __STL_RTSP_REQUEST_H__

#include <string>
#include <map>
#include "STL_Json.h"

namespace STL
{
    // Request-Line   = Method SP Request-URI SP RTSP-Version CRLF
    class STL_RtspRequest
    {
    public:
    public:
        STL_RtspRequest();
        ~STL_RtspRequest() = default;

    public:
        void setMethod(std::string method);
        void setUri(std::string uri);
        void setBody(std::string body);
        void setCSeq(int cseq);
        void addHeader(std::string header, std::string value);
        void setContentType(std::string type);
        void setBodyFromFile(std::string filePath);
        void setBodyFromJson(JSONCPP::Value body);

    public: //认证
        void addAuthorization(std::string value);
        void addBasicAuthorization(std::string username, std::string password, std::string realm);
        void addDigestAuthorization(std::string username, std::string password, std::string realm, std::string nonce, std::string qop = "", std::string algorithm = "", std::string opaque = "");

    public:
        std::string genRequstMessage();

    private: //Digest认证使用的临时参数(部分报文信息用户计算，所以发送时计算认证头域)
        bool m_Digest;// 是否使用Digest认证
        std::string m_username;
        std::string m_password;
        std::string m_realm;
        std::string m_nonce;
        std::string m_qop;
        std::string m_algorithm;
        std::string m_opaque;

    public:
        std::string m_method;
        std::string m_uri;
        std::string m_version;
        std::map<std::string, std::string> m_headers;
        std::string m_body;

    public: // m_uri
        std::string m_path;
        std::string m_parameter;
        std::string m_query;
        std::map<std::string, std::string> m_query_map;
        std::string m_fragment;
    };
}

#endif //__STL_RTSP_REQUEST_H__